package 递归;

import java.math.BigInteger;
import java.util.Scanner;

public class 斐波那契求模 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        BigInteger p = new BigInteger(scanner.next());
        BigInteger sum = new BigInteger("0");
        for (int i = 1; i <= n ; i++) {
            sum = sum.add(fblq(i));
            sum.remainder(fblq(m));
        }
        System.out.println(sum.remainder(p));
    }
    static BigInteger fblq(int n){
        if(n==1||n==2){
            return new BigInteger("1");
        }
        return fblq(n-1).add(fblq(n-2));
    }

}
